<?php

namespace App\Http\Controllers\backend;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Model\backend\ProjectStages;

class ProgramController extends Controller
{
	function __construct(Request $req){
		
		$session = $req->session()->get('member');
		if($session['gid'] != 1) abort(403,'Unauthorized action.');
	}
	
	public function index(){
		
		$stages = ProjectStages::get();
		return view('backend.program.index',compact('stages'));
	}
	
	function store(request $req){

		$stages = new ProjectStages;
		$stages->name = $req->name;
		$stages->save();
		echo $stages;
	}
	
	function destroy($id){
		
		$res = ProjectStages::where('sid',$id)->delete();
		return $res;
	}
}
